home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Interactive 7
/
PC World Interactive 7.iso
/
program
/
ctutor.exe
/
ANSWERS
/
CH07_2.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-05-15
|
794b
|
36 lines
#include "stdio.h"
void main()
{
int index, array1[10], array2[10], arrays[10];
for(index = 0 ; index < 10 ; index = index + 1) {
array1[index] = 2 + 2 * index;
array2[index] = 10 * (index + 1);
}
for(index = 0 ; index < 10 ; index = index + 1)
arrays[index] = array1[index] + array2[index];
for(index = 0 ; index < 10 ; index = index + 1)
printf("%4d %4d + %4d = %4d\n", (index + 1), array1[index],
array2[index], arrays[index]);
}
/* Result of execution
1 2 + 10 = 12
2 4 + 20 = 24
3 6 + 30 = 36
4 8 + 40 = 48
5 10 + 50 = 60
6 12 + 60 = 72
7 14 + 70 = 84
8 16 + 80 = 96
9 18 + 90 = 108
10 20 + 100 = 120
*/